{% extends 'layout.jinja' %}
{% from 'datum.jinja' import datum with context %}
{% block title %} &raquo; {{ page.name }}{% endblock %}
{% block heading %} &raquo; <span id="page_name">{{ page.name }}</span>{% endblock %}
{% block head %}{{ load_js('show') }}{% endblock %}
{% block content %}

<div id="metadata">

  <ul{{ ' style="display: none"' if not page.metadata }} id="metadata_list">
    {% if page.metadata %}
      {% for datum_tuple in page.metadata.iteritems() %}
        {{ datum(datum_tuple) }}
      {% endfor %}
    {% endif %}
    <li id="edit_metadata" style="display: none">
      <form id="metadata_form">
        <input type="text" name="predicate" autocomplete="off"/>:
        <input type="text" name="object" autocomplete="off"/>
        <span id="edit_controls">
          {{ image('save.png',class='control',alt='Save',title='Save',id='save_metadata_image') }}
          {{ link('cancel',class='control',id='cancel_edit_link',accesskey='c') }}
        </span>
      </form>
    </li>
    <li id="add_metadata" {{ 'style="display: none"' if not page.metadata }}>
      {{ link('Add '+image('add.png'),id='add_metadata_link',accesskey='a') }}
    </li>
  </ul>
  <span style="display: none" id="metadata_controls">
    {{ image("edit.png",alt='Edit',title='Edit',id='edit_metadata_image',class='control') }}
    {{ image("delete.png",alt='Delete',title='Delete',id='unset_metadata_image',class='control')}}
  </span>
  <span style="display: none" id="saving_indicator" class="control">
    Saving&hellip;{{ image('spinner.gif') }} 
  </span>
    
  {% if not page.metadata %}
    <p class="notice">
      No metadata.
      {{ link('Add '+image('add.png'),id='add_first_metadata_link',accesskey='a') }}
    </p>
  {% endif %}  
    
</div>

<div id="backlinks">
  {% if page.backlinks %}
    <ul id="backlinks">
      {% for backlink in page.backlinks.iteritems() %}
        <li class="backlink">{{ pagelink(backlink[0]) }} of {{ pagelink(backlink[1]) }}</li>
      {% endfor %}
    </ul>
  {% else %}
    <p class="notice">No backlinks.</p>
  {% endif %}
</div>

<div id="description" title="double-click to edit">
  {% include 'description-html.jinja' %}
</div>

<!-- body...? -->

{% endblock %}
{% block sidebar_actions %}
<span class="sidebar_heading">This Page:</span>
<ul>
  <li>
    <a href="#" id="rename_link">rename</a>
    <form id="rename_form" action="{{ url('/rename/%s' % page['name']) }}" style="display: none">
      <input name="newname" type="text" size="15"/>
      <input type="submit" value="Go"/>
      <a href="#" id="rename_cancel">cancel</a>
    </form>
  </li>
  <li>
    <a href="#" id="delete_link">delete</a>
    <span id="delete_prompt" style="display: none">
      really? <a href="{{ url('/delete/%s' % page['name']) }}" id="delete_yes">yes</a>/<a href="#" id="delete_no">no</a>
    </span>
  </li>
</ul>
{% endblock %}